###############################################################################
# SuperLinks                                                                  #
# Copyright (c) 2000-2007 Greg Nolle (http://greg.nolle.co.uk)                #
###############################################################################
# This program is free software; you can redistribute it and/or modify it     #
# under the terms of the GNU General Public License as published by the Free  #
# Software Foundation; either version 2 of the License, or (at your option)   #
# any later version.                                                          #
#                                                                             #
# This program is distributed in the hope that it will be useful, but WITHOUT #
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or       #
# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for   #
# more details.                                                               ##                                                                             #
# You should have received a copy of the GNU General Public License along     #
# with this program; if not, write to the Free Software Foundation, Inc.,     #
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.                 #
###############################################################################
# ControlPanel/Output/Login.pm.pl -> Login module                             #
###############################################################################
# DON'T EDIT BELOW UNLESS YOU KNOW WHAT YOU'RE DOING!                         #
###############################################################################
package Skin::CP::Login;

BEGIN { require "System.pm.pl"; import System qw($SYSTEM); }
BEGIN { require "General.pm.pl"; import General qw($GENERAL); }
require "Standard.pm.pl";

use HTML::Dialog;
use strict;

sub new {
  my ($class) = @_;
  my $self    = {};
  return bless ($self, $class);
}

sub DESTROY { }

###############################################################################
# show subroutine
sub show {
  my $self = shift;
  my %in = (error => undef, @_);

  my $LANGUAGE = {
    "INVALID" => {
      "Username"    => qq~<li>The Username you entered is invalid.~,
      "Password"    => qq~<li>The Password you entered is invalid.~
    },
    "ERROR"         => qq~<p><font class="error">There were errors:<ul>[%error%]</ul></font>~
  };

  #----------------------------------------------------------------------#
  # Printing page...                                                     #

  my $Dialog = HTML::Dialog->new();

  $in{'error'} = &Standard::ProcessError(LANGUAGE => $LANGUAGE, ERROR => $in{'error'});

  my $Body = $Dialog->TableRow(items => [{ body => "To login to the Control Panel please enter your username and password below:".$in{'error'}, colspan => 2 }]);
    
  $Body .= $Dialog->FormTextBox(
    name     => "Username",
    subject  => "Username"
  );
  $Body .= $Dialog->FormTextBox(
    name     => "Password",
    subject  => "Password",
    password => 1
  );
  $Body .= $Dialog->FormCheckBox(
    name     => "FORM_STORE_DETAILS",
    items    => [
      { value => "1", label => "Remember your username and password?" }
    ]
  );
  $Body .= $Dialog->FormButton(
    items    => [
      { type => "submit", value => "Login" },
      { type => "reset", value => "Cancel" }
    ], join => "&nbsp;"
  );

  $Body = $Dialog->Table(body => $Body);
  $Body = $Dialog->StandardPage(
    body    => $Body,
    header  => "Login",
    form    => 1,
    hiddens => [
      { name => "CP", value => "1" },
      { name => "action", value => "DoLogin" },
      { name => "REFERER", value => ($SL::QUERY{'action'} eq "Login" || $SL::QUERY{'action'} eq "DoLogin" || $SL::QUERY{'action'} eq "Logout" ? $SL::QUERY{'REFERER'} : $SL::QUERY{'action'}) }
    ]
  );

  return $Body;
}

1;